package com.lihao.wanandroid.ui.project

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.lihao.wanandroid.R
import com.lihao.wanandroid.app.weight.glide.GlideUtil
import com.lihao.wanandroid.data.model.ArticleResponse
import me.jessyan.autosize.utils.AutoSizeUtils.dp2px

class ProjectAdapter : BaseQuickAdapter<ArticleResponse, BaseViewHolder>(R.layout.item_project),
    LoadMoreModule {


    override fun convert(holder: BaseViewHolder, item: ArticleResponse) {
        item.let {
            holder.setText(R.id.tvTitle, it.title)
                .setText(R.id.tvContent, it.desc)
                .setText(R.id.tvAuthor, it.author)
                .setText(R.id.tvTime, it.niceDate)
            Glide.with(context).load(it.envelopePic)
                .apply(GlideUtil.roundImage(dp2px(context, 4f)))
                .into(holder.getView(R.id.image))
        }
    }
}